<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../js/cookie.js"></script>
    
</head>
<body>
    <div>
        <h2>个人主页</h2>
        <div id="userbox">
            <p>请,你还未登录</p>
            <a href="./login.html">登录</a>
            <a href="./register.html">注册</a>
        </div>
    </div>

    <script>
        var userbox = document.getElementById("userbox")
        var lgc = getCookie("lgc")   // 用来判断用户是否已经登录 
        
        if(lgc){
            userbox.innerHTML = `欢迎你, ${lgc}  <button onclick="logout()">退出</button>` 
        }

        function logout(){
            delCookie('lgc')
            location.reload()
        }
    </script>
</body>
</html>